package com.app.configuration.web.websocket;

import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import javax.websocket.server.ServerEndpointConfig.Configurator;

import org.apache.log4j.Logger;
public class ShiroUserSessionConfigurator extends Configurator{
	
	private static final Logger log = Logger.getLogger(ShiroUserSessionConfigurator.class);
	@Override
    public void modifyHandshake(ServerEndpointConfig sec,
            HandshakeRequest request, HandshakeResponse response) {
        // TODO Auto-generated method stub
		
		try{
//			User user = Globa.getUser();
//			String strId = Globa.getStrId();
//	        String strUserId = Globa.getLoginName();
//	        String strSchoolId = Globa.getStrSchoolId();
//	        String strName = Globa.getStrCname();
//	        String strUnitId = Globa.getStrUnitId();
//	        String[] strTeamIds= user.getTeam_ids();
//	        String[] strRoleIds=user.getRole_ids();
//	        sec.getUserProperties().put("strId", strId);
//	        sec.getUserProperties().put("strUserId", strUserId);
//	        sec.getUserProperties().put("strSchoolId", strSchoolId);
//	        sec.getUserProperties().put("strName", strName);
//	        sec.getUserProperties().put("strUnitId", strUnitId);
//	        if(strTeamIds!=null&&strTeamIds.length>0) {
//	        	String strTeamId="";
//	        	for(String teamId:strTeamIds) {
//	        		strTeamId+=","+teamId;
//	        	}
//	        	strTeamId =strTeamId.substring(1);
//	        	sec.getUserProperties().put("strTeamId", strTeamId);
//	        }else {
//	        	sec.getUserProperties().put("strTeamId", "");
//	        }
//	        if(strRoleIds!=null&&strRoleIds.length>0) {
//	        	String strRoleId="";
//	        	for(String roleId:strRoleIds) {
//	        		strRoleId+=","+roleId;
//	        	}
//	        	strRoleId =strRoleId.substring(1);
//	        	sec.getUserProperties().put("strRoleId", strRoleId);
//	        }else {
//	        	sec.getUserProperties().put("strRoleId", "");
//	        }
		}catch(Exception e){
			e.printStackTrace();
			log.info(e);
		}
    }
}
